﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuestFramework.Combat
{
    public class Dice
    {
        private DiceType typeOfDice;
        private int numberOfDice;
        private Random randomGenerator;

        public DiceType TypeOfDice
        {
            get { return typeOfDice; }
            set { typeOfDice = value; } 
        }

        public int NumberOfDice
        {
            get { return numberOfDice; }
            set { numberOfDice = value; }
        }

        public Dice()
        {
            randomGenerator = new Random();
            numberOfDice = 1;
            typeOfDice = DiceType.D6;
        }

        public Dice(DiceType diceType) : base()
        {
            typeOfDice = diceType;
            numberOfDice = 1;
        }

        public Dice(DiceType diceType, int diceCount)
        {
            typeOfDice = diceType;
            numberOfDice = diceCount;
        }

        public int Roll()
        {
            int rolledValue = 0;

            Random randomRoll = new Random();

            for (int currentDie = 0; currentDie < numberOfDice; currentDie++)
            {
                rolledValue = rolledValue + randomRoll.Next(1, (int)typeOfDice + 1);
            }

            return rolledValue;
        }
    }
}
